﻿<%@ Page Language="C#" %>
<%@ import Namespace="System.Data.OleDb" %>
<%@ import Namespace="System.Data" %>
<%    OleDbConnection conn = null;
try
{
    Response.ContentType = "text/xml";
    conn = DBOp.DbConn;
    OleDbCommand comm = conn.CreateCommand();
    String function = Request.Params["params"];
    function = function.Replace("年单位面积能耗频度统计", "");
    int maxDian = 300;
    if (function == "居住建筑")
    {
        maxDian = 200;
    }
    comm.CommandText = "select max(建筑年单位面积能耗),min(建筑年单位面积能耗) from JZ where 建筑功能 = '"+function+"' and jz.建筑年单位面积能耗 <> 0 and jz.建筑年单位面积能耗 < "+maxDian;
    System.Data.DataTable dt = new System.Data.DataTable();
    OleDbDataAdapter oda = new OleDbDataAdapter(comm);    
    oda.Fill(dt);
    double max = double.Parse(dt.Rows[0][0].ToString());
    double min = double.Parse(dt.Rows[0][1].ToString());
    double min1 = min;
    double distance = (max - min) / 10;
    ArrayList al = new ArrayList();
    for (int i = 0; i < 10; i++)
    {
        comm.CommandText = "select count(objectid) from JZ where 建筑功能 = '"+function+"' and 建筑年单位面积能耗 between " + min1 + " and " + (min1 + distance);
        dt = new System.Data.DataTable();
        oda = new OleDbDataAdapter(comm);
        oda.Fill(dt);
        al.Add(dt.Rows[0][0]);
        min1 += distance;
    }
    min1 = min;
    
    Random r = new Random(0);
     %><chart palette='2' caption='<%=Request.Params["params"] %>' showBorder="1" subCaption="（栋）" shownames='1' showvalues='1' formatNumberScale='0' labelDisplay='ROTATE' slantLabels='1'  decimals='2' baseFontSize='12' baseFontFamily='宋体'>
    <%    foreach (object dr in al)    {
               %><set label='<%=min1 %>-<%=min1 + distance %>' value='<%=dr.ToString() %>' isSliced="<%=r.Next(2) %>"/>                                                    
               <%                             
              min1 += distance;
               } %><styles>
         <definition>
            <style name='caption' type='font' font='宋体' size='16' color='000000' /> 
            <style name='label' type='font' font='宋体' size='12' Bold='1' color='000000' /> 
         </definition>
         <application>
            <apply toObject='DataLabels' styles='label' />
            <apply toObject='DataValues' styles='label' />
            <apply toObject='Caption' styles='caption' />
            <apply toObject='ToolTip' styles='label' />
            <apply toObject='Legend' styles='label' />
            <apply toObject='ToolTip' styles='label' />
            <apply toObject='ToolTip' styles='label' />
         </application>   
    </styles> 
</chart>

<% 
    }
catch (Exception ex) { 
    
}
    finally{
    if(conn != null)
    conn.Close();} %>